// 项目组件
<template>
  <div class="project">
    <p class="title">任务跟进</p>
    <el-table :data="tableData" style="width: 90%; margin: 0 auto" height="400">
      <el-table-column prop="project_content" label="分配内容">
      </el-table-column>
      <el-table-column prop="nick_name" label="负责人姓名"> </el-table-column>
      <el-table-column prop="progress_status" label="进度">
        <template slot-scope="scope">
          <!-- <span>{{ scope.row.progress_status }}%</span> -->
          <el-progress :percentage="scope.row.progress_status"></el-progress>
        </template>
      </el-table-column>
      <el-table-column prop="remark" label="备注"> </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            type="text"
            size="small"
            @click="addOrUpdateHandle(scope.row)"
            >跟进</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <el-dialog
      title="进度跟进"
      :close-on-click-modal="false"
      :visible.sync="visible"
    >
      <el-slider v-model="value1"></el-slider>
      <span slot="footer" class="dialog-footer">
        <el-button @click="visible = false">取消</el-button>
        <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tableData: [],
      visible: false,
      value1: 0,
      dataP: null,
    };
  },
  mounted() {
    this.getTaskList();
  },
  methods: {
    addOrUpdateHandle(val) {
      this.dataP = val;
      this.value1 = val.progress_status;
      this.$nextTick(() => {
        this.visible = true;
      });
    },
    dataFormSubmit() {
      this.$http({
        url: this.$http.adornUrl(`/business/eprojectschedule/update`),
        method: "post",
        data: this.$http.adornData({
          id: this.dataP.id,
          projectId: this.dataP.projectId,
          progressStatus: this.value1,
        }),
      }).then(({ data }) => {
        if (data && data.code === 0) {
          this.$message({
            message: "操作成功",
            type: "success",
            duration: 1500,
            onClose: () => {
              this.visible = false;
              this.getTaskList();
            },
          });
        } else {
          this.$message.error(data.msg);
        }
      });
    },
    getTaskList() {
      this.$http({
        url: this.$http.adornUrl("/business/eprojectschedule/query"),
        method: "get",
        params: this.$http.adornParams({
          pageSize: "999",
          flag: 1,
          charge_person_id: localStorage.getItem("userId"),
          isFinish: 0,
        }),
      }).then(({ data }) => {
        if (data && data.code === 0) {
          this.tableData = data.page.records;
        }
      });
    },
  },
};
</script>

<style lang="scss">
.project {
  width: 1000px;
  overflow: hidden;
  height: 500px;
  background-color: #fff;
  box-shadow: 0 2px 12px 0 #d3dce6;
  margin: 20px auto;
  font-size: 30px;
  border-radius: 5px;
  .title {
    font-size: 20px;
    font-weight: 600;
    margin-left: 20px;
  }
}
</style>
